﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bule.Malbilden.Domain
{
    public class EatenItem : IEaten
    {
        public EatenItem() { }
        
        public EatenItem(IEatable food, double weight)
            : this(food, weight, new DateTime(1900, 1, 1)) { }

        public EatenItem(IEatable food, double weight, DateTime date)
        {
            Weight = weight;
            Food = food;
            Date = date;
        }

        public virtual int Id { get; set; }
        public virtual double Weight { get; set; }
        public virtual IEatable Food { get; set; }
        public virtual string Name { get { return Food.Name; } }
        public virtual DateTime Date { get; set; }
        
        public virtual string PortionName { get { return Food.PortionName; } }
        public virtual double PortionSize { get { return Food.PortionSize; } }
        
        public virtual double Portions
        {
            get { return Weight / Food.PortionSize; }
            set { Weight = value * Food.PortionSize; }
        }

        public virtual NutritionData TotalNutritionalValue
        {
            get { return Food.NutritionPerHundredGrams * (Weight / 100); }
        }
    }
}
